﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using SocialPaltformSample.Resources;
using SocialPlatformSDK;
using SocialPlatformSDK.Services.Util;

namespace SocialPaltformSample
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            // 用于本地化 ApplicationBar 的示例代码
            //BuildLocalizedApplicationBar();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            TencentSocFactory tencentfactory = TencentSocFactory.Instance;
            tencentfactory.Init();


            try
            {
                // 验证 OAuth 相关配置.
                tencentfactory.Validate();
                NavigationService.Navigate(new Uri("/Page2.xaml", UriKind.RelativeOrAbsolute));

            }
            catch (MissingAccessTokenExcception ex)
            {

                NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.RelativeOrAbsolute));
            }



        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            SinaSocFactory sinafactory = SinaSocFactory.Instance;
            sinafactory.Init();


            try
            {
                // 验证 OAuth 相关配置.
                sinafactory.Validate();
                NavigationService.Navigate(new Uri("/Page2.xaml", UriKind.RelativeOrAbsolute));

            }
            catch (MissingAccessTokenExcception ex)
            {

                NavigationService.Navigate(new Uri("/SinaPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            RenRenSocFactory renrefactory = RenRenSocFactory.Instance;
            renrefactory.Init();

            try
            {
                // 验证 OAuth 相关配置.
                renrefactory.Validate();
                NavigationService.Navigate(new Uri("/Page2.xaml", UriKind.RelativeOrAbsolute));

            }
            catch (MissingAccessTokenExcception ex)
            {

                NavigationService.Navigate(new Uri("/RenRenPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }

    }
}